package typage;

import java.util.*;
import ast.*;

// un profile est simplement une liste de types
public class Profile {

    public String l[];

    public boolean equals(Object o) {
	Profile p = (Profile)o;
	if (p.l.length != l.length) return false;
	for (int i = 0; i < l.length; i++)
	    if (!l[i].equals(p.l[i])) return false;
	return true;
    }

    public int hashCode() {
	int h = 0;
	for (int i = 0; i < l.length; i++)
	    h = 19 * h + l[i].hashCode();
	return h<0 ? -h : h;
    }

    public Profile (String[] a) { l = a; }
    
    public Profile ( Vector<String> vect  )
    {  	
    	l = new String[ vect.size() ] ;
    	int i = 0;
    	for (Iterator it = vect.iterator(); it.hasNext();)
    	{
    	    l[i++] = ( (String)it.next() ) ;
        }
    }
    
    public Profile(VarList vl) 
    {
		l = new String[ListUtil.length(vl)];
		int i = 0;
		for (Iterator it = vl.iterator(); it.hasNext();)
		    l[i++] = ((Var)it.next()).var_ty.ty_val;
    }
    
    public String toString()
    {
    	String ret = "";
    	for (int i = 0; i < l.length; i++)
    	{
    		if(i != 0)ret = ret+"_"; 
    		
    		if( l[i].equals("bool")) ret = ret + "B" ;
    		else	ret = ret+l[i] ;
    		
    	}
    	return ret;
    }

}
